/**
 @file ctc_usw_chip_cli.c

 @date 2012-3-20

 @version v2.0

---file comments----
*/

/****************************************************************
 *
 * Header Files
 *
 ***************************************************************/
#include "sal.h"
#include "ctc_cli.h"
#include "ctc_cli_common.h"
#include "ctc_api.h"
#include "ctcs_api.h"
#include "ctc_chip.h"
#include "ctc_eunit.h"
#include "ctc_error.h"
#include "ctc_debug.h"
#include "ctc_usw_chip_cli.h"
#include "dal.h"
#include "sys_usw_eunit.h"

#define CTC_CLI_TBL_NAME_SIZE           128

extern int32
sys_usw_register_check_table(uint8 lchip, uint8 type, uint8 recover_en, uint32 tbl_id, char* file);
extern int32
sys_usw_register_dump_table(uint8 lchip, uint8 type, uint32 tbl_id, char* file);
extern int32
sys_usw_register_sdb_config(uint8 lchip, uint8 op_type, uint8 enable);
extern int32
sys_usw_register_show_sdb_status(uint8 lchip, uint8 type, char* table_name);
extern uint32
drv_sdb_get_tbl_by_ram(uint8 lchip, uint32 ram_id);
int32
drv_sdb_get_tbl_size(uint8 lchip, uint32 tbl_id);
extern int32
sys_usw_register_show_sdb_changed_table(uint8 lchip, char* tbl_name, uint32 start_time, uint32 end_time);
extern int32
sys_usw_datapath_show_status(uint8 lchip);
extern int32
sys_usw_datapath_show_xpipe(uint8 lchip);
extern int32
sys_usw_datapath_show_info(uint8 lchip, uint8 type, uint32 start, uint32 end, uint8 is_all);
extern int32
sys_usw_chip_show_ser_status(uint8 lchip);

extern int32 
sys_usw_chip_free_rsv_resource(uint8 lchip);
#include "usw/include/drv_enum.h"

extern int32
drv_sdb_set_stop_store(uint8 lchip, uint8 enable);

extern int32
drv_ser_set_ecc_simulation_idx(uint8 lchip, uint8 mode, uint32 tbl_idx);

extern int32
sys_usw_register_show_status(uint8 lchip);
#if defined(TSINGMA) || defined(TSINGMA_MX) || defined(TSINGMA_GX) || defined(ARCTIC)
extern int32
sys_tsingma_lb_hash_show_hash_cfg(uint8 lchip,ctc_lb_hash_config_t hash_cfg);

extern int32
sys_tsingma_lb_hash_show_template(uint8 lchip,uint8 template_id);
#endif

#if defined(ARCTIC)
extern int32
sys_at_hash_show_selector_remap(uint8 lchip);
#endif

extern int32
sys_usw_wb_show_module_version(uint8 lchip);

extern int32
sys_usw_mac_show_mcu_version(uint8 lchip);
extern int32
sys_usw_mac_show_mcu_debug_info(uint8 lchip,uint8 mcu_id);
extern int32 sys_usw_mac_set_mcu_enable(uint8 lchip, uint32 enable);
extern int32 sys_usw_mac_get_mcu_enable(uint8 lchip, uint32* enable);
extern int32 sys_usw_mac_set_mcu_port_enable(uint8 lchip, uint32 gport, uint32 enable);
extern int32 sys_usw_mac_get_mcu_port_enable(uint8 lchip, uint32 gport, uint32* enable);
extern int32
sys_usw_parser_set_hash_mask(uint8 lchip, uint8 hash_type, uint8 pkt_field_type, uint16 sel_bitmap);
extern int32 sys_usw_dmps_serdes_download_firmware(uint8 lchip, uint16 serdes_id, uint8 flag);

CTC_CLI(ctc_cli_parser_set_hash_mask,
    ctc_cli_parser_set_hash_mask_cmd,
    "parser hash (linkagg | ecmp | flow) (macsa|macda|ipsa|ipda) mask VALUE",
    CTC_CLI_PARSER_STR,
    "Load balance hash mask",
    "Linkagg hash mask field",
    "Ecmp hash mask field",
    "Flow hash mask field",
    "Add macsa mask, each bit control 8 bits of data",
    "Add macda mask, each bit control 8 bits of data",
    "Add ipsa mask, each bit control 8 bits of data",
    "Add ipda mask, each bit control 8 bits of data",
    "Mask",
    "Value"
    )
{
    uint8 index = 0;
    uint16 sel_bitmap = 0;
    int32 ret = 0;
    uint8 hash_usage = 0;
    ctc_field_key_type_t type = 0;
    index = CTC_CLI_GET_ARGC_INDEX("linkagg");
    if (index != 0xFF)
    {
        hash_usage = 1;                             /*SYS_PARSER_HASH_USAGE_LINKAGG */
    }
    index = CTC_CLI_GET_ARGC_INDEX("ecmp");
    if (index != 0xFF)
    {
        hash_usage = 0;                              /*SYS_PARSER_HASH_USAGE_ECMP*/
    }
    index = CTC_CLI_GET_ARGC_INDEX("flow");
    if (index != 0xFF)
    {
        hash_usage = 2;                              /*SYS_PARSER_HASH_USAGE_FLOW*/
    }
    index = CTC_CLI_GET_ARGC_INDEX("macsa");
    if (index != 0xFF)
    {
        type = 0;
        CTC_CLI_GET_UINT16("sel_bitmap", sel_bitmap, argv[index + 1]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("macda");
    if (index != 0xFF)
    {
        type = 1;
        CTC_CLI_GET_UINT16("sel_bitmap", sel_bitmap, argv[index + 1]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("ipsa");
    if (index != 0xFF)
    {
        type = 2;
        CTC_CLI_GET_UINT16("sel_bitmap", sel_bitmap, argv[index + 1]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("ipda");
    if (index != 0xFF)
    {
        type = 3;
        CTC_CLI_GET_UINT16("sel_bitmap", sel_bitmap, argv[index + 1]);
    }

    ret = sys_usw_parser_set_hash_mask(g_api_lchip, hash_usage, type, sel_bitmap);
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return ret;
}

CTC_CLI(ctc_cli_usw_datapath_show_status,
        ctc_cli_usw_datapath_show_status_cmd,
        "show datapath status",
        CTC_CLI_SHOW_STR,
        "Datapath module",
        "Status")
{
    int32 ret = CLI_SUCCESS;

    ret = sys_usw_datapath_show_status(g_api_lchip);
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_usw_datapath_show_xpipe,
        ctc_cli_usw_datapath_show_xpipe_cmd,
        "show datapath xpipe ",
        CTC_CLI_SHOW_STR,
        "Datapath module",
        "X-PIPE")
{
    int32 ret = CLI_SUCCESS;

    ret = sys_usw_datapath_show_xpipe(g_api_lchip);
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_usw_datapath_show_info,
        ctc_cli_usw_datapath_show_info_cmd,
        "show datapath info (hss|serdes|clktree|calendar) (((start-idx SIDX) (end-idx EIDX))|)",
        CTC_CLI_SHOW_STR,
        "Datapath module",
        "Information",
        "Hss",
        "SerDes",
        "Clock Tree",
        "Calendar",
        "Start index",
        "Index",
        "End index",
        "Index")
{
    int32 ret = CLI_SUCCESS;
    uint32 index = 0;
    uint32 start_idx = 0;
    uint32 end_idx = 0;
    uint8 is_all = 1;
    uint8 type = 0;

    index = CTC_CLI_GET_ARGC_INDEX("hss");
    if(index != 0xFF)
    {
         type = 0;
    }

    index = CTC_CLI_GET_ARGC_INDEX("serdes");
    if(index != 0xFF)
    {
         type = 1;
    }

    index = CTC_CLI_GET_ARGC_INDEX("clktree");
    if(index != 0xFF)
    {
         type = 2;
    }
    index = CTC_CLI_GET_ARGC_INDEX("calendar");
    if(index != 0xFF)
    {
         type = 3;
    }
    index = CTC_CLI_GET_ARGC_INDEX("start-idx");
    if(index != 0xFF)
    {
       CTC_CLI_GET_UINT32("start-idx", start_idx, argv[index+1]);
       is_all = 0;
    }

    index = CTC_CLI_GET_ARGC_INDEX("end-idx");
    if(index != 0xFF)
    {
       CTC_CLI_GET_UINT32("end-idx", end_idx, argv[index+1]);
       is_all = 0;
    }

    ret = sys_usw_datapath_show_info(g_api_lchip, type, start_idx, end_idx, is_all);
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}


extern dal_op_t g_dal_op;

uint8 g_usw_debug = 0;

CTC_CLI(ctc_cli_usw_debug,
        ctc_cli_usw_debug_cmd,
        "debug driver (on|off)",
        "Debug",
        "Driver",
        "On",
        "Off")
{
    uint8 index = 0;

    index = CTC_CLI_GET_ARGC_INDEX("on");
    if(0xFF != index)
    {
        g_usw_debug = 1;
    }
    else
    {
        g_usw_debug = 0;
    }

    return CLI_SUCCESS;
}


CTC_CLI(ctc_cli_usw_chip_set_ecc_simulation_store,
        ctc_cli_usw_chip_set_ecc_simulation_store_cmd,
        "chip ecc simulation stop store (enable | disable) ",
        "Chip module",
        "Drv ecc recover",
        "Simulation",
        "Stop",
        "Store",
        "Enable",
        "Disable")
{
    int32   ret = CLI_SUCCESS;
    uint8   enable = 0;
    uint8   index = 0;



    index = CTC_CLI_GET_ARGC_INDEX("enable");
    if(0xFF != index)
    {
        enable = 1;
    }
    else
    {
        enable = 0;
    }

    ret = drv_sdb_set_stop_store(g_api_lchip, enable);

    if (ret)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_usw_chip_sdb_global_config,
        ctc_cli_usw_chip_sdb_global_config_cmd,
        "chip sdb (read-from-hw|sdb-en) (enable | disable) ",
        "Chip module",
        "SDB",
        "Read from hardware",
        "SDB Enable",
        "Enable",
        "Disable")
{
    int32   ret = CLI_SUCCESS;
    uint8   enable = 0;
    uint8   index = 0;
    uint8   op_type = 0;


    index = CTC_CLI_GET_ARGC_INDEX("sdb-en");
    if (INDEX_VALID(index))
    {
        op_type = 1;
    }

    index = CTC_CLI_GET_ARGC_INDEX("enable");
    if(0xFF != index)
    {
        enable = 1;
    }
    else
    {
        enable = 0;
    }

    ret = sys_usw_register_sdb_config(g_api_lchip, op_type, enable);
    if (ret)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_usw_chip_show_sdb_status,
        ctc_cli_usw_chip_show_sdb_status_cmd,
        "show chip sdb (status |table-info (static|dynamic|tcam|ram-id RAM-ID | tbl-id TBL-ID|))",
        CTC_CLI_SHOW_STR,
        "Chip Module",
        "SDB Module",
        "Status",
        "Table Info", "Static table", "Dynamic table", "Tcam key",
        "Ram id", 
        "Ram id value",
        "Table id",
        "Table id value")
{
    int32   ret = CLI_SUCCESS;
    uint8   index = 0;
    uint8   type = 0;
    uint32  ram_id = 0;
    uint32  tbl_id = MaxTblId_t;

    index = CTC_CLI_GET_ARGC_INDEX("table-info");
    if (INDEX_VALID(index))
    {
        if (!argv[index+1])
        {
            type = 0xFF;    /*All*/
        }
        else if (CTC_CLI_STR_EQUAL_ENHANCE("static", index + 1))
        {
            type = 2;
        }
        else if (CTC_CLI_STR_EQUAL_ENHANCE("dynamic", index + 1))
        {
            type = 3;
        }
        else if (CTC_CLI_STR_EQUAL_ENHANCE("tcam", index + 1))
        {
            type = 4;
        }
        else if (CTC_CLI_STR_EQUAL_ENHANCE("ram-id", index + 1))
        {
            CTC_CLI_GET_UINT32("ram-id", ram_id, argv[index+2]);
            drv_sdb_get_tbl_by_ram(g_api_lchip, ram_id);
            return CLI_SUCCESS;
        }
        else if (CTC_CLI_STR_EQUAL_ENHANCE("tbl-id", index + 1))
        {
            CTC_CLI_GET_UINT32("tbl-id", tbl_id, argv[index+2]);
            drv_sdb_get_tbl_size(g_api_lchip, tbl_id);
            return CLI_SUCCESS;
        }
        else
        {
            type = 0xFF;    /*All*/
        }
    }
    else
    {
       type = 1;
    }
    ret = sys_usw_register_show_sdb_status(g_api_lchip, type, NULL);
    if (ret)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}

#define ctc_cli_sdb_marker      (CTC_VTY_CLIENT(vty)->sdb_marker)
CTC_CLI(ctc_cli_usw_chip_sdb_set_marker,
        ctc_cli_usw_chip_sdb_set_marker_cmd,
        "chip sdb (ts-marker ID| clear-marker|)",
        "Chip module",
        "SDB",
        "Timestamp marker", "Marker ID",
        "Clear marker")
{
    int32 ret = CLI_SUCCESS;
    uint8 index = 0;
    uint8 marker_id = 0;

    index = CTC_CLI_GET_ARGC_INDEX("ts-marker");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_UINT8_RANGE("marker id", marker_id, argv[index+1], 0, CTC_CLI_TIMESTAMP_MARKER_NUM-1);
        if(marker_id < CTC_CLI_TIMESTAMP_MARKER_NUM)
        {
            ctc_cli_sdb_marker[marker_id] = (uint32)sal_time(NULL);
        }
    }
    else
    {
        ctc_cli_sdb_marker[0] = 0;
        ctc_cli_sdb_marker[1] = 0;
    }
    return ret;
}

CTC_CLI(ctc_cli_usw_chip_sdb_show_changed_table,
        ctc_cli_usw_chip_sdb_show_changed_table_cmd,
        "show chip sdb changed-table {table-name NAME| start-time TIME | ts-marker1 ID| end-time TIME| ts-marker2 ID|}",
        CTC_CLI_SHOW_STR,
        "Chip Module",
        "SDB Module",
        "Changed Table",
        "Table Name", "TABLE NAME",
        "Start Time", "XXXX-XX-XX-XX:XX:XX",
        "Timestamp marker1", "Marker ID",
        "End Time", "XXXX-XX-XX-XX:XX:XX",
        "Timestamp marker2", "Marker ID")
{
    int32   ret = CLI_SUCCESS;
    uint8   index = 0;
    uint8   ts_marker[CTC_CLI_TIMESTAMP_MARKER_NUM] = {0};
    struct tm user_ts;
    uint32  start_time = 0, end_time = 0;
    char    tbl_name[CTC_CLI_TBL_NAME_SIZE] = "";

    sal_memset(&user_ts, 0,sizeof(user_ts));

    index = CTC_CLI_GET_ARGC_INDEX("table-name");
    if (index != 0xFF)
    {
        sal_strncpy(tbl_name, argv[index+1], CTC_CLI_TBL_NAME_SIZE - 1);
    }

    index = CTC_CLI_GET_ARGC_INDEX("start-time");
    if (index != 0xFF)
    {
        ret = ctc_cmd_get_timestamp("start time", argv[index+1], &user_ts);
        if (ret)
        {
            return CLI_ERROR;
        }
        start_time = (uint32)sal_mktime(&user_ts);
    }

    index = CTC_CLI_GET_ARGC_INDEX("ts-marker1");
    if (index != 0xFF)
    {
        CTC_CLI_GET_UINT8_RANGE("ts marker1", ts_marker[0], argv[index+1], 0, CTC_CLI_TIMESTAMP_MARKER_NUM-1);
        start_time = ctc_cli_sdb_marker[ts_marker[0]];
    }

    index = CTC_CLI_GET_ARGC_INDEX("end-time");
    if (index != 0xFF)
    {
        ret = ctc_cmd_get_timestamp("end time", argv[index+1], &user_ts);
        if (ret)
        {
            return CLI_ERROR;
        }
        end_time = (uint32)sal_mktime(&user_ts);
    }

    index = CTC_CLI_GET_ARGC_INDEX("ts-marker2");
    if (index != 0xFF)
    {
        CTC_CLI_GET_UINT8_RANGE("ts marker2", ts_marker[1], argv[index+1], 0, CTC_CLI_TIMESTAMP_MARKER_NUM-1);
        end_time = ctc_cli_sdb_marker[ts_marker[1]];
    }

    ret = sys_usw_register_show_sdb_changed_table(g_api_lchip, tbl_name, start_time, end_time);
    if (ret)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_usw_chip_check_table,
        ctc_cli_usw_chip_check_table_cmd,
        "chip sdb table-check (static|dynamic|tcam|tbl-id ID|) {recover-en|log FILE|}",
        "Chip module",
        "SDB",
        "Table check",
        "Static table", 
        "Dynamic table", 
        "Tcam key",
        "Table ID, per table check",
        "Value",
        "Enable recover",
        "Log to file", 
        "File name")
{
    int32  ret = CLI_SUCCESS;
    char* file = NULL;
    uint32 tbl_id = 0;

    uint8 index = 0;
    uint8 type = 0xFF;
    uint8 recover_en = 0;

 
    if (!argv[0])
    {
        type = 0xFF;
    }
    else if (CTC_CLI_STR_EQUAL_ENHANCE("static", 0))
    {
        type = 0;
    }
    else if (CTC_CLI_STR_EQUAL_ENHANCE("dynamic", 0))
    {
        type = 1;
    }
    else if (CTC_CLI_STR_EQUAL_ENHANCE("tcam", 0))
    {
        type = 2;
    }
    else if (CTC_CLI_STR_EQUAL_ENHANCE("tbl-id", 0))
    {
        type = 3;
        CTC_CLI_GET_UINT32("tbl-id", tbl_id, argv[1]);
    }

    index = CTC_CLI_GET_ARGC_INDEX("recover-en");
    if (index != 0xFF)
    {
        recover_en = 1;
    }

    index = CTC_CLI_GET_ARGC_INDEX("log");
    if (index != 0xFF)
    {
        file = argv[index+1];
    }
    ret = sys_usw_register_check_table(g_api_lchip, type, recover_en, tbl_id, file);

    if (ret)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_usw_chip_dump_table,
        ctc_cli_usw_chip_dump_table_cmd,
        "chip sdb table-dump (static|dynamic|tcam|tbl-id ID|) (log FILE|)",
        "Chip module",
        "SDB",
        "Table dump",
        "Static table", 
        "Dynamic table", 
        "Tcam key",
        "Table ID, dump specified table", 
        "Value",
        "Log to file", 
        "File name")
{
    int32  ret = CLI_SUCCESS;
    char* file = NULL;
    uint32 tbl_id = 0;
    uint8 index = 0;
    uint8 type = 0xFF;

    if (!argv[0])
    {
        type = 0xFF;
    }
    else if (CTC_CLI_STR_EQUAL_ENHANCE("static", 0))
    {
        type = 0;
    }
    else if (CTC_CLI_STR_EQUAL_ENHANCE("dynamic", 0))
    {
        type = 1;
    }
    else if (CTC_CLI_STR_EQUAL_ENHANCE("tcam", 0))
    {
        type = 2;
    }
    else if (CTC_CLI_STR_EQUAL_ENHANCE("tbl-id", 0))
    {
        type = 3;
        CTC_CLI_GET_UINT32("tbl-id", tbl_id, argv[1]);
    }

    index = CTC_CLI_GET_ARGC_INDEX("log");
    if (index != 0xFF)
    {
        file = argv[index+1];
    }
    ret = sys_usw_register_dump_table(g_api_lchip, type, tbl_id, file);
    if (ret)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}
CTC_CLI(ctc_cli_usw_chip_show_ecc_status,
        ctc_cli_usw_chip_show_ecc_status_cmd,
        "show chip ser status",
        CTC_CLI_SHOW_STR,
        "Chip module",
        "SER",
        "Status")
{
    int32  ret = CLI_SUCCESS;

    ret = sys_usw_chip_show_ser_status(g_api_lchip);

    if (ret)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}


CTC_CLI(ctc_cli_usw_chip_set_ecc_simulation_idx,
        ctc_cli_usw_chip_set_ecc_simulation_idx_cmd,
        "chip ecc simulation (disable | (tbl-index INDEX)) ",
        "Chip module",
        "Ecc error recover",
        "Simulation",
        "Disable",
        "Table index",
        "Index num")
{
    int32  ret = CLI_SUCCESS;
    uint8  index = 0;
    uint8  enable = 0;
    uint32 idx_value = 0;



    index = CTC_CLI_GET_ARGC_INDEX("disable");
    if (index != 0xFF)
    {
        enable = 0;
    }
    else
    {
        enable = 1;
    }

    index = CTC_CLI_GET_ARGC_INDEX("tbl-index");
    if (index != 0xFF)
    {
        CTC_CLI_GET_UINT32("tbl-index", idx_value, argv[index + 1]);
    }

    ret = drv_ser_set_ecc_simulation_idx(g_api_lchip, enable, idx_value);

    if (ret)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

/* source master and queue*/
CTC_CLI(ctc_cli_usw_master_queue,
    ctc_cli_usw_master_queue_cmd,
    "master queue config",
    "master",
    "queue",
    "config")
{
    int32 ret = CLI_SUCCESS;
    char *line = "source master.txt";

    ret = ctc_vti_command(g_ctc_vti, line);
    if(ret)
    {
        ctc_cli_out("%s\n", line);
    }

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_usw_chip_set_glb_acl_lkup_en,
        ctc_cli_usw_chip_set_glb_acl_lkup_en_cmd,
        "chip global-cfg acl-lkup-property priority PRIORITY_ID direction (ingress | egress ) acl-en (disable |(enable "\
        "tcam-lkup-type (l2 | l3 |l2-l3 | vlan | l3-ext | l2-l3-ext |"\
        "cid | interface | forward | forward-ext | copp | udf | stk-hdr) {class-id CLASS_ID |(use-port-bitmap | use-metadata|use-logic-port )| use-mapped-vlan |use-wlan|}))",
        "chip module",
        "Global config",
        "Acl lookup property",
        "Acl lookup priority",
        "PRIORITY_ID",
        "Direction",
        "Ingress",
        "Egress",
        "Global acl en",
        "Disable function",
        "Enable function",
        "Tcam lookup type",
        "L2 key",
        "L3 key",
        "L2 L3 key",
        "Vlan key",
        "L3 extend key",
        "L2 L3 extend key",
        "CID  key",
        "Interface key",
        "Forward key",
        "Forward extend key",
        "Copp key",
        "Udf key",
        "Stacking key",
        "Port acl use class id",
        "CLASS_ID",
        "Global acl use port-bitmap",
        "Global acl use metadata",
        "Global acl use logic-port",
        "Use mapped vlan",
        "Use wlan")
{
    int32  ret = CLI_SUCCESS;
    uint8  index = 0;

    ctc_acl_property_t prop;

    sal_memset(&prop,0,sizeof(ctc_acl_property_t));

    CTC_CLI_GET_UINT8("priority",prop.acl_priority,argv[0] );

    if(CLI_CLI_STR_EQUAL("disable",2))
    {
        prop.acl_en = 0;
    }
    else
    {
        prop.acl_en = 1;
    }

    index = CTC_CLI_GET_ARGC_INDEX("ingress");
    if(0xFF != index)
    {
        prop.direction= CTC_INGRESS;

    }
    else
    {
        prop.direction= CTC_EGRESS;
    }

    index = CTC_CLI_GET_ARGC_INDEX("tcam-lkup-type");
    if(0xFF != index)
    {
        if(CTC_CLI_STR_EQUAL_ENHANCE("l2",index + 1))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_L2;
        }
        else if(CTC_CLI_STR_EQUAL_ENHANCE("l3",index + 1))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_L3;
        }
        else if(CTC_CLI_STR_EQUAL_ENHANCE("l2-l3",index + 1))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_L2_L3;
        }
        else if(CLI_CLI_STR_EQUAL("vlan",index + 1))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_VLAN;
        }
        else if(CTC_CLI_STR_EQUAL_ENHANCE("l3-ext",index + 1))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_L3_EXT;
        }
        else if(CTC_CLI_STR_EQUAL_ENHANCE("l2-l3-ext",index + 1 ))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_L2_L3_EXT;
        }
        else if(CLI_CLI_STR_EQUAL("cid",index + 1 ))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_CID;
        }
        else if(CLI_CLI_STR_EQUAL("interface",index + 1 ))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_INTERFACE;
        }
        else if(CTC_CLI_STR_EQUAL_ENHANCE("forward",index + 1 ))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_FORWARD;
        }
        else if(CTC_CLI_STR_EQUAL_ENHANCE("forward-ext",index + 1 ))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_FORWARD_EXT;
        }
        else if(CTC_CLI_STR_EQUAL_ENHANCE("copp",index + 1 ))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_COPP;
        }
        else if(CTC_CLI_STR_EQUAL_ENHANCE("udf",index + 1 ))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_UDF;
        }
        else if (CTC_CLI_STR_EQUAL_ENHANCE("stk-hdr",index + 1 ))
        {
            prop.tcam_lkup_type = CTC_ACL_TCAM_LKUP_TYPE_STK_HDR;
        }
    }

    index = CTC_CLI_GET_ARGC_INDEX("class-id");
    if(0xFF != index)
    {
        CTC_CLI_GET_UINT16("class-id",prop.class_id, argv[index + 1] );
    }

    index = CTC_CLI_GET_ARGC_INDEX("use-port-bitmap");
    if(0xFF != index)
    {
        CTC_SET_FLAG(prop.flag, CTC_ACL_PROP_FLAG_USE_PORT_BITMAP);
    }

    index = CTC_CLI_GET_ARGC_INDEX("use-metadata");
    if(0xFF != index)
    {
        CTC_SET_FLAG(prop.flag, CTC_ACL_PROP_FLAG_USE_METADATA);
    }

    index = CTC_CLI_GET_ARGC_INDEX("use-mapped-vlan");
    if(0xFF != index)
    {
        CTC_SET_FLAG(prop.flag, CTC_ACL_PROP_FLAG_USE_MAPPED_VLAN);
    }

    index = CTC_CLI_GET_ARGC_INDEX("use-wlan");
    if(0xFF != index)
    {
        CTC_SET_FLAG(prop.flag, CTC_ACL_PROP_FLAG_USE_WLAN);
    }

	index = CTC_CLI_GET_ARGC_INDEX("use-logic-port");
    if(0xFF != index)
    {
        CTC_SET_FLAG(prop.flag, CTC_ACL_PROP_FLAG_USE_LOGIC_PORT);
    }

    if(g_ctcs_api_en)
    {
         ret = ctcs_global_ctl_set(g_api_ldev, CTC_GLOBAL_ACL_LKUP_PROPERTY, &prop);
    }
    else
    {
        ret = ctc_global_ctl_set(CTC_GLOBAL_ACL_LKUP_PROPERTY, &prop);
    }

    if (ret < 0)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return ret;
}



CTC_CLI(ctc_cli_usw_chip_get_glb_acl_lkup_en,
        ctc_cli_usw_chip_get_glb_acl_lkup_en_cmd,
        "show chip global-cfg acl-lkup-property priority PRIORITY_ID direction (ingress | egress ) ",
        CTC_CLI_SHOW_STR,
        "Chip module",
        "Global config",
        "Acl lookup property",
        "Acl lookup priority",
        "PRIORITY_ID",
        "Direction",
        "Ingress",
        "Egress" )
{
    int32  ret = CLI_SUCCESS;
    uint8  index = 0;

    ctc_acl_property_t acl_lkup_prop;

    sal_memset(&acl_lkup_prop,0,sizeof(ctc_acl_property_t));

    CTC_CLI_GET_UINT8("priority",acl_lkup_prop.acl_priority,argv[0] );


    index = CTC_CLI_GET_ARGC_INDEX("ingress");
    if(0xFF != index)
    {
        acl_lkup_prop.direction= CTC_INGRESS;

    }
    else
    {
        acl_lkup_prop.direction= CTC_EGRESS;
   	}

    if(g_ctcs_api_en)
    {
         ret = ctcs_global_ctl_get(g_api_ldev, CTC_GLOBAL_ACL_LKUP_PROPERTY, &acl_lkup_prop);
    }
    else
    {
        ret = ctc_global_ctl_get(CTC_GLOBAL_ACL_LKUP_PROPERTY, &acl_lkup_prop);
    }

    if (ret < 0)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    ctc_cli_out("Direction: %s\n", acl_lkup_prop.direction ?  "EGRESS" :"INGRESS" );
    ctc_cli_out("Acl_priority : %u\n", acl_lkup_prop.acl_priority);
    ctc_cli_out("Tcam lkup type : %u\n", acl_lkup_prop.tcam_lkup_type);
    ctc_cli_out("class id : %u\n", acl_lkup_prop.class_id);
    if(CTC_FLAG_ISSET(acl_lkup_prop.flag,CTC_ACL_PROP_FLAG_USE_PORT_BITMAP))
    {
       ctc_cli_out("Used port bitmap as key\n");
    }
    if(CTC_FLAG_ISSET(acl_lkup_prop.flag,CTC_ACL_PROP_FLAG_USE_LOGIC_PORT))
    {
       ctc_cli_out("Used logic port as key\n");
    }
    if(CTC_FLAG_ISSET(acl_lkup_prop.flag,CTC_ACL_PROP_FLAG_USE_METADATA))
    {
        ctc_cli_out("Used metadata as key\n");
    }
    if(CTC_FLAG_ISSET(acl_lkup_prop.flag,CTC_ACL_PROP_FLAG_USE_MAPPED_VLAN))
    {
        ctc_cli_out("Used mapped vlan as key\n");
    }
    if(CTC_FLAG_ISSET(acl_lkup_prop.flag,CTC_ACL_PROP_FLAG_USE_WLAN))
    {
        ctc_cli_out("Used capwap info vlan as key\n");
    }
    return ret;
}

CTC_CLI(ctc_cli_chip_set_ipmc_config,
        ctc_cli_chip_set_ipmc_config_cmd,
        "chip global-cfg ipmc-property l2mc MODE",
        "Chip module",
        "Global config",
        "Ipmc property",
        "IP based l2mc",
        "If set,ip base L2MC lookup failed,will use mac based L2MC lookup result")
{
    int32 ret = CLI_SUCCESS;
    ctc_global_ipmc_property_t property;

    sal_memset(&property, 0, sizeof(ctc_global_ipmc_property_t));
    CTC_CLI_GET_UINT8("value", property.ip_l2mc_mode, argv[0]);

    if(g_ctcs_api_en)
    {
        ret = ctcs_global_ctl_set(g_api_ldev, CTC_GLOBAL_IPMC_PROPERTY, &property);
    }
    else
    {
        ret = ctc_global_ctl_set(CTC_GLOBAL_IPMC_PROPERTY, &property);
    }

    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return ret;

}

CTC_CLI(ctc_cli_chip_show_ipmc_config,
        ctc_cli_chip_show_ipmc_config_cmd,
        "show chip global-cfg ipmc-property",
        "Show",
        "Chip module",
        "Global config",
        "Ipmc property")
{
    int32 ret = CLI_SUCCESS;
    ctc_global_ipmc_property_t property;

    sal_memset(&property, 0, sizeof(ctc_global_ipmc_property_t));
    if(g_ctcs_api_en)
    {
         ret = ctcs_global_ctl_get(g_api_ldev, CTC_GLOBAL_IPMC_PROPERTY, &property);
    }
    else
    {
        ret = ctc_global_ctl_get(CTC_GLOBAL_IPMC_PROPERTY, &property);
    }

    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    ctc_cli_out("Show chip global-cfg ipmc info\n");
    ctc_cli_out("==============================\n");
    ctc_cli_out("l2mc mode : %u\n", property.ip_l2mc_mode);
    ctc_cli_out("==============================\n");

    return ret;
}

CTC_CLI(ctc_cli_usw_chip_dump_db,
        ctc_cli_usw_chip_dump_db_cmd,
        "chip global-cfg dump-db ({port|vlan|linkagg|chip|ftm|nexthop|l2|l3if|ipuc|ipmc|ip-tunnel|scl|acl|qos|security|stats|mpls|oam|aps|ptp|\
        dma|interrupt|packet|pdu|mirror|bpe|stacking|overlay|ipfix|efd|monitor|fcoe|trill|wlan|npm|vlan-mapping|dot1ae|sync-ether|app-vlanport|\
        datapath|register|diag|srv6|sc-oam|dtel|pon|xdata|flexe} | all) {(detail)|( file FILE_NAME)|}",
        "Chip module",
        "Global config",
        "Dump db",
        "Port module",
        "Vlan module",
        "Linkagg module",
        "Chip module",
        "Ftm module",
        "Nexthop module",
        "L2 module",
        "L3if module",
        "Ipuc module",
        "Ipmc module",
        "Ip-tunnel module",
        "Scl module",
        "Acl module",
        "Qos module",
        "Security module",
        "Stats module",
        "Mpls module",
        "Oam module",
        "Aps module",
        "Ptp module",
        "Dma module",
        "Interrupt module",
        "Packet module",
        "Pdu module",
        "Mirror module",
        "Bpe module",
        "Stacking module",
        "Overlay module",
        "Ipfix module",
        "Efd module",
        "Monitor module",
        "Fcoe module",
        "Trill module",
        "Wlan module",
        "Npm module",
        "Vlan-mapping module",
        "Dot1ae module",
        "Sync-ether module",
        "App-vlanport module",
        "Datapath module",
        "Register module",
        "Diag module",
        "SRv6 module",
        "Sc- oam module",
        "Dtel module",
        "Pon module",
        "Xdata module",
        "FlexE module",
        "All module",
        "Detail data",
        "File",
        "File name and route")
{
    int32  ret    = CLI_SUCCESS;
    uint8  index = 0;
    ctc_global_dump_db_t dump_param;
    sal_memset(&dump_param, 0, sizeof(ctc_global_dump_db_t));
    index = CTC_CLI_GET_ARGC_INDEX("file");
    if (0xFF != index)
    {
        if (sal_strlen(argv[argc - 1]) > sizeof(dump_param.file))
        {
            ctc_cli_out("ERROR: File name is too long!\n\n");
            return CLI_ERROR;
        }
        sal_memcpy(dump_param.file, argv[argc - 1], sal_strlen(argv[argc - 1]));
    }
    index = CTC_CLI_GET_ARGC_INDEX("detail");
    if (0xFF != index)
    {
        dump_param.detail = 1;
    }
    index = CTC_CLI_GET_ARGC_INDEX("port");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_PORT);
    }
    index = CTC_CLI_GET_ARGC_INDEX("vlan");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_VLAN);
    }
    index = CTC_CLI_GET_ARGC_INDEX("linkagg");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_LINKAGG);
    }
    index = CTC_CLI_GET_ARGC_INDEX("chip");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_CHIP);
    }
    index = CTC_CLI_GET_ARGC_INDEX("ftm");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_FTM);
    }
    index = CTC_CLI_GET_ARGC_INDEX("nexthop");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_NEXTHOP);
    }
    index = CTC_CLI_GET_ARGC_INDEX("l2");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_L2);
    }
    index = CTC_CLI_GET_ARGC_INDEX("l3if");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_L3IF);
    }
    index = CTC_CLI_GET_ARGC_INDEX("ipuc");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_IPUC);
    }
    index = CTC_CLI_GET_ARGC_INDEX("ipmc");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_IPMC);
    }
    index = CTC_CLI_GET_ARGC_INDEX("ip-tunnel");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_IP_TUNNEL);
    }
    index = CTC_CLI_GET_ARGC_INDEX("scl");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_SCL);
    }
    index = CTC_CLI_GET_ARGC_INDEX("acl");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_ACL);
    }
    index = CTC_CLI_GET_ARGC_INDEX("qos");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_QOS);
    }
    index = CTC_CLI_GET_ARGC_INDEX("security");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_SECURITY);
    }
    index = CTC_CLI_GET_ARGC_INDEX("stats");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_STATS);
    }
    index = CTC_CLI_GET_ARGC_INDEX("mpls");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_MPLS);
    }
    index = CTC_CLI_GET_ARGC_INDEX("oam");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_OAM);
    }
    index = CTC_CLI_GET_ARGC_INDEX("aps");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_APS);
    }
    index = CTC_CLI_GET_ARGC_INDEX("ptp");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_PTP);
    }
    index = CTC_CLI_GET_ARGC_INDEX("dma");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_DMA);
    }
    index = CTC_CLI_GET_ARGC_INDEX("interrupt");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_INTERRUPT);
    }
    index = CTC_CLI_GET_ARGC_INDEX("packet");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_PACKET);
    }
    index = CTC_CLI_GET_ARGC_INDEX("pdu");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_PDU);
    }
    index = CTC_CLI_GET_ARGC_INDEX("mirror");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_MIRROR);
    }
    index = CTC_CLI_GET_ARGC_INDEX("bpe");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_BPE);
    }
    index = CTC_CLI_GET_ARGC_INDEX("stacking");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_STACKING);
    }
    index = CTC_CLI_GET_ARGC_INDEX("overlay");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_OVERLAY);
    }
    index = CTC_CLI_GET_ARGC_INDEX("ipfix");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_IPFIX);
    }
    index = CTC_CLI_GET_ARGC_INDEX("efd");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_EFD);
    }
    index = CTC_CLI_GET_ARGC_INDEX("monitor");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_MONITOR);
    }
    index = CTC_CLI_GET_ARGC_INDEX("fcoe");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_FCOE);
    }
    index = CTC_CLI_GET_ARGC_INDEX("trill");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_TRILL);
    }
    index = CTC_CLI_GET_ARGC_INDEX("wlan");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_WLAN);
    }
    index = CTC_CLI_GET_ARGC_INDEX("npm");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_NPM);
    }
    index = CTC_CLI_GET_ARGC_INDEX("vlan-mapping");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_VLAN_MAPPING);
    }
    index = CTC_CLI_GET_ARGC_INDEX("dot1ae");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_DOT1AE);
    }
    index = CTC_CLI_GET_ARGC_INDEX("sync-ether");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_SYNC_ETHER);
    }
    index = CTC_CLI_GET_ARGC_INDEX("app-vlanport");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_APP_VLAN_PORT);
    }
    index = CTC_CLI_GET_ARGC_INDEX("datapath");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_DATAPATH);
    }
    index = CTC_CLI_GET_ARGC_INDEX("all");
    if (0xFF != index)
    {
        dump_param.bit_map[0] = 0xffffffff;
        dump_param.bit_map[1] = 0xffffffff;
    }
    index = CTC_CLI_GET_ARGC_INDEX("register");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_REGISTER);
    }
    index = CTC_CLI_GET_ARGC_INDEX("diag");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_DIAG);
    }
    index = CTC_CLI_GET_ARGC_INDEX("srv6");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_SRV6);
    }
    index = CTC_CLI_GET_ARGC_INDEX("sc-oam");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_SC_OAM);
    }
    index = CTC_CLI_GET_ARGC_INDEX("dtel");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_DTEL);
    }
    index = CTC_CLI_GET_ARGC_INDEX("pon");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_PON);
    }
    index = CTC_CLI_GET_ARGC_INDEX("xdata");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_XDATA);
    }
    index = CTC_CLI_GET_ARGC_INDEX("flexe");
    if (0xFF != index)
    {
        CTC_BMP_SET(dump_param.bit_map, CTC_FEATURE_FLEXE);
    }
    if (g_ctcs_api_en)
    {
        ret = ctcs_global_ctl_set(g_api_ldev, CTC_GLOBAL_DUMP_DB, (void*)&dump_param);
    }
    else
    {
        ret = ctc_global_ctl_set(CTC_GLOBAL_DUMP_DB, (void*)&dump_param);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return ret;
}
CTC_CLI(ctc_cli_chip_set_search_depth,
        ctc_cli_chip_set_search_depth_cmd,
        "chip global-cfg search-depth DEPTH",
        "Chip module",
        "Global config",
        "Search depth",
        "Value")
{
    int32  ret = CLI_SUCCESS;
    uint32 depth = 0;

    CTC_CLI_GET_UINT32("Value", depth, argv[0]);

    if(g_ctcs_api_en)
    {
        ret = ctcs_global_ctl_set(g_api_ldev, CTC_GLOBAL_FDB_SEARCH_DEPTH, &depth);
    }
    else
    {
        ret = ctc_global_ctl_set(CTC_GLOBAL_FDB_SEARCH_DEPTH, &depth);
    }

    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return ret;

}

CTC_CLI(ctc_cli_chip_get_search_depth,
        ctc_cli_chip_get_search_depth_cmd,
        "show chip global-cfg search-depth",
        CTC_CLI_SHOW_STR,
        "Chip module",
        "Global config",
        "Search depth")
{
    int32 ret = 0;
    uint32 depth = 0;

    if(g_ctcs_api_en)
    {
        ret = ctcs_global_ctl_get(g_api_ldev, CTC_GLOBAL_FDB_SEARCH_DEPTH, &depth);
    }
    else
    {
        ret = ctc_global_ctl_get(CTC_GLOBAL_FDB_SEARCH_DEPTH, &depth);
    }

    if (ret < 0)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    ctc_cli_out("Show chip global-cfg search depth\n");
    ctc_cli_out("==============================\n");
    ctc_cli_out("Search depth : %u\n", depth);
    ctc_cli_out("==============================\n");
    return CLI_SUCCESS;
}
#if 1
extern int cli_com_source_file(ctc_cmd_element_t *, ctc_vti_t *, int, char **);
extern ctc_cmd_element_t cli_com_source_file_cmd;

/**
 @brief The function is to initialize datapath
*/
CTC_CLI(ctc_cli_chip_show_status,
        ctc_cli_chip_show_status_cmd,
        "show chip status",
        "Show",
        "Chip module",
        "Status")
{
    int32 ret = CLI_SUCCESS;

    ret = sys_usw_register_show_status(g_api_lchip);
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return ret;
}

CTC_CLI(ctc_cli_usw_chip_show_wb_version,
        ctc_cli_usw_chip_show_wb_version_cmd,
        "show warmboot version",
        "Show",
        "Warmboot module",
        "Version")
{
    uint8 lchip = 0;

    sys_usw_wb_show_module_version(lchip);

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_usw_chip_show_mcu_version,
        ctc_cli_usw_chip_show_mcu_version_cmd,
        "show chip mcu version",
        CTC_CLI_SHOW_STR,
        "Chip module",
        "MCU",
        "Version")
{
    sys_usw_mac_show_mcu_version(g_api_lchip);

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_usw_chip_show_mcu_info,
        ctc_cli_usw_chip_show_mcu_info_cmd,
        "show chip mcu info (mcu-id MCU-ID|)",
        CTC_CLI_SHOW_STR,
        "Chip module",
        "MCU",
        "Debug Information",
        "Mcu-id",
        "MCU-ID")
{
    uint8 mcu_id = 0;
    uint8 index = 0;
    
    index = CTC_CLI_GET_ARGC_INDEX("mcu-id");
    if (0xFF != index)
    {
        CTC_CLI_GET_UINT8("mcu-id", mcu_id, argv[index + 1]);
        sys_usw_mac_show_mcu_debug_info(g_api_lchip, mcu_id);
    }
    else
    {
        sys_usw_mac_show_mcu_debug_info(g_api_lchip, 0xff);
    }
    
    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_usw_chip_set_mcu_on,
        ctc_cli_usw_chip_set_mcu_on_cmd,
        "chip mcu (enable | disable) (gport GPHYPORT_ID |)",
        "chip module",
        "MCU",
        "Enable",
        "Disable",
        "gport",
        CTC_CLI_GPHYPORT_ID_DESC)
{
    int32 ret = CLI_SUCCESS;
    uint8 index = 0;
    uint32 value = 0;
    uint32 gport = 0;
    uint8 lchip = 0;
    uint8 port_cli_flag = 0;

    index = CTC_CLI_GET_ARGC_INDEX("enable");
    if (0xFF != index)
    {
        value = 1;
    }

    index = CTC_CLI_GET_ARGC_INDEX("disable");
    if (0xFF != index)
    {
        value = 0;
    }

    index = CTC_CLI_GET_ARGC_INDEX("gport");
    if (index != 0xFF)
    {
        CTC_CLI_GET_UINT32_RANGE("gport", gport, argv[index + 1], 0, CTC_MAX_UINT32_VALUE);
        port_cli_flag = 1;
    }
    else
    {
        port_cli_flag = 0;
    }

    lchip = g_api_lchip;

    if (port_cli_flag)
    {
        ret = sys_usw_mac_set_mcu_port_enable(lchip, gport, value);
    }
    else
    {
        ret = sys_usw_mac_set_mcu_enable(lchip, value);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_usw_chip_show_mcu_status,
        ctc_cli_usw_chip_show_mcu_status_cmd,
        "show chip mcu status (gport (GPHYPORT_ID | all)|)",
        CTC_CLI_SHOW_STR,
        "chip module",
        "MCU",
        "Status",
        "gport",
        CTC_CLI_GPHYPORT_ID_DESC,
        "All infomation")
{
    int32 ret = CLI_SUCCESS;
    uint8 index = 0;
    uint32 value = 0;
    uint8 lchip = 0;
    uint32 gport = 0;
    uint8  port_cli_flag = 0;
    uint8  port_all_flag = 0;

    index = CTC_CLI_GET_ARGC_INDEX("gport");
    if (index != 0xFF)
    {
        if (CLI_CLI_STR_EQUAL("all", 1))
        {
            port_all_flag = 1;
        }
        else
        {
            CTC_CLI_GET_UINT32_RANGE("gport", gport, argv[index + 1], 0, CTC_MAX_UINT32_VALUE);
        }
        port_cli_flag = 1;
    }
    else
    {
        port_cli_flag = 0;
    }

    lchip = g_api_lchip;

    if (port_cli_flag)
    {
        if (port_all_flag)
        {
            ctc_cli_out("-----------------------------------\n");
            ctc_cli_out(" Port id\tPort enable?\n");
            ctc_cli_out("-----------------------------------\n");
            for (gport = 0; gport < 64; gport++)
            {
                ret = sys_usw_mac_get_mcu_port_enable(lchip, gport, &value);
                if (ret < 0)
                {
                    ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
                    return CLI_ERROR;
                }
                ctc_cli_out("% 8d\t%s\n", gport, value?"enable\t":"\tdisable");
            }

            ctc_cli_out("-----------------------------------\n");
        }
        else
        {
            ret = sys_usw_mac_get_mcu_port_enable(lchip, gport, &value);
            if (ret < 0)
            {
                ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
                return CLI_ERROR;
            }
            ctc_cli_out("MCU port %d status:  %s\n", gport, value?"enable":"disable");
        }
    }
    else
    {
        ret = sys_usw_mac_get_mcu_enable(lchip, &value);
        if (ret < 0)
        {
            ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
            return CLI_ERROR;
        }
        ctc_cli_out("%-20s:  %s\n","MCU status", value?"enable":"disable");
    }

    return CLI_SUCCESS;
}


int32
tsingma_datapath_init(ctc_vti_t* vty)
{
#if 0
    char str[100] = "";
    char* argv[2];
    uint8 board_type = 0;

    ctc_cli_out_basic("arctic_datapath_init start !!!!!!!!!!!!!!!!!!!!\n");
    /*source datapath*/
    sal_strcpy(str, "/systest/asiclab/data/asic/arcticemul/asic/pp_fchip_init/pp_init_basic.tcl");
    argv[0] = str;
    cli_com_source_file(&cli_com_source_file_cmd, g_ctc_vti, 1, argv);

    if (0 == board_type)
    {
        //sal_strcpy(str, "/data/tsingma2_emulboard/asic/datapath_init/DataPathInit_TsingMa2_20x25G_2x100G.tcl");
        sal_strcpy(str, "/systest/asiclab/data/cmodel/datapath/DataPathInit_Arctic_Chip0_128x100GR1_Shell.tcl");
    }
    else if (1 == board_type)
    {
        sal_strcpy(str, "/data/tsingmaemul/asic/datapath_init/DataPathInit_TsingMa_48x1G_4x10G_2x40G.tcl");
    }
    else if (2 == board_type)
    {
        sal_strcpy(str, "/data/tsingmaemul/asic/datapath_init/DataPathInit_TsingMa_48x1G_8x10G_8x25G.tcl");
    }
    argv[0] = str;
    cli_com_source_file(&cli_com_source_file_cmd, g_ctc_vti, 1, argv);

    //sal_strcpy(str, "/data/tsingma2_emulboard/asic/datapath_init/MacShim_32x25G_4x100G.tcl");
    //argv[0] = str;
    //cli_com_source_file(&cli_com_source_file_cmd, g_ctc_vti, 1, argv);

    sal_strcpy(str, "/systest/asiclab/data/asic/arcticemul/asic/datapath_init/qmgr_flush.tcl");
    argv[0] = str;
    cli_com_source_file(&cli_com_source_file_cmd, g_ctc_vti, 1, argv);
    ctc_cli_out_basic("arctic_datapath_init end !!!!!!!!!!!!!!!!!!!!\n");
#endif
    return 0;
}

#ifdef EMULATION_ENV
int32
_sys_tmm_cmodel_datapath_init(uint8 board_type, uint8 datapath_type)
{
    char str[100] = "";
    char* argv[2];
    int32 ret = 0;
    //uint8 board_type = 0;

    ctc_cli_out_basic("_sys_tmm_cmodel_datapath_init start !!!!!!!!!!!!!!!!!!!!\n");

    switch (board_type)
    {
    case 0:
    case 9:
        sal_strcpy(str, "/data2/qicx/tm2/cm_dp/MacShim_48x25G.tcl");
        printf("---- load MacShim_48x25G.tcl ---- \n");
        break;
    case 1:
        sal_strcpy(str, "/data2/qicx/tm2/cm_dp/MacShim_24x50GR2.tcl");
        printf("---- MacShim_24x50GR2.tcl ---- \n");
        break;
    case 2:
        sal_strcpy(str, "/data2/qicx/tm2/cm_dp/MacShim_32x50GR1.tcl");
        printf("---- MacShim_32x50GR1.tcl ---- \n");
        break;
    case 3:
        sal_strcpy(str, "/data2/qicx/tm2/cm_dp/MacShim_16x100GR2.tcl");
        printf("---- load MacShim_16x100GR2.tcl ---- \n");
        break;
    case 4:
        sal_strcpy(str, "/data2/qicx/tm2/cm_dp/MacShim_12x100GR4.tcl");
        printf("---- load MacShim_12x100GR4.tcl ---- \n");
        break;
    case 5:
        sal_strcpy(str, "/data2/qicx/tm2/cm_dp/MacShim_12x40G.tcl");
        printf("---- load MacShim_12x40G.tcl ---- \n");
        break;
    case 6:
        sal_strcpy(str, "/data2/qicx/tm2/cm_dp/MacShim_48x10G.tcl");
        printf("---- load MacShim_48x10G.tcl ---- \n");
        break;
    case 7:
        sal_strcpy(str, "/data2/qicx/tm2/cm_dp/MacShim_32x25G_4x200G.tcl");
        printf("---- load MacShim_32x25G_4x200G.tcl ---- \n");
        break;
    case 8:
        sal_strcpy(str, "/data2/qicx/tm2/cm_dp/MacShim_16x50GR1_2x400G.tcl");
        printf("---- load MacShim_16x50GR1_2x400G.tcl ---- \n");
        break;
    }
    argv[0] = str;
    ret = cli_com_source_file(&cli_com_source_file_cmd, g_vty_client.ctc_vti, 1, argv);

    if (ret)
    {
       return CLI_ERROR;
    }

    //sal_strcpy(str, "/data2/qicx/tm2/cm_dp/manual_patch.tcl");
    //argv[0] = str;
    //cli_com_source_file(&cli_com_source_file_cmd, g_vty_client.ctc_vti, 1, argv);
    ctc_cli_out_basic("_sys_tmm_cmodel_datapath_init end !!!!!!!!!!!!!!!!!!!!\n");

    return 0;
}
int32
sys_at_cmodel_datapath_init(uint8 board_type, uint8 datapath_type)
{
    char str[256] = "";
    char* argv[2];
    //int32 ret = 0;
    sal_file_t local_fp = NULL;


    local_fp = sal_fopen("init_source.cfg", "r");
    if (NULL == local_fp)
    {
        return CTC_E_NONE;
    }
    while (NULL != sal_fgets(str, 200, local_fp))
    {
        if (str[0] == '\0' || str[0] == '\n' || str[0] == '\r' || str[0] == '#')
        {
            continue;
        }
        str[sal_strlen(str) - 1] = '\0';
        argv[0] = str;
        ctc_cli_out_basic("%s\n", str);
        cli_com_source_file(&cli_com_source_file_cmd, g_vty_client.ctc_vti, 1, argv);
    }
    sal_fclose(local_fp);

    ctc_cli_out_basic("sys_at_cmodel_datapath_init end !!!!!!!!!!!!!!!!!!!!\n");


    // sal_strcpy(str, "/systest/asiclab/data/asic/arcticemul/asic/pp_fchip_init/pp_init_basic.tcl");
    // argv[0] = str;
    // cli_com_source_file(&cli_com_source_file_cmd, g_vty_client.ctc_vti, 1, argv);
    // sal_task_sleep(2000);
    // sal_strcpy(str, "/systest/asiclab/data/asic/arcticemul/asic/pp_fchip_init/manual_patch.tcl");
    // argv[0] = str;
    // cli_com_source_file(&cli_com_source_file_cmd, g_vty_client.ctc_vti, 1, argv);
    // switch (board_type)
    // {
    // case 1:
    //     sal_strcpy(str, "/systest/asiclab/data/asic/arcticemul/asic/0422_datapath_init/DataPathInit_Arctic_Chip0_128x100GR1_Shell.tcl");
    //     printf("---- DataPathInit_Arctic_Chip0_128x100GR1_Shell.tcl ---- \n");
    //     break;
    // default:
    //     sal_strcpy(str, "/systest/asiclab/data/asic/arcticemul/asic/0422_datapath_init/DataPathInit_Arctic_Chip0_64x200GR2_Shell.tcl");
    //     printf("---- DataPathInit_Arctic_Chip0_64x200GR2_Shell.tcl ---- \n");
    //     break;
    // }
    // argv[0] = str;
    // ret = cli_com_source_file(&cli_com_source_file_cmd, g_vty_client.ctc_vti, 1, argv);
    // if (ret)
    // {
    //    return CLI_ERROR;
    // }
    // sal_strcpy(str, "/systest/asiclab/data/asic/arcticemul/asic/0422_datapath_init/qmgr_flush.tcl");
    // argv[0] = str;
    // cli_com_source_file(&cli_com_source_file_cmd, g_vty_client.ctc_vti, 1, argv);
    // ctc_cli_out("sys_at_cmodel_datapath_init end !!!!!!!!!!!!!!!!!!!!\n");

    return 0;
}
/*
CTC_CLI(ctc_usw_chip_cli_port_set_mac_en_emu,
        ctc_usw_chip_cli_port_set_mac_en_emu_cmd,
        "port GPHYPORT_ID mac (enable | disable) (bmp BMP|)",
        CTC_CLI_PORT_M_STR,
        CTC_CLI_GPHYPORT_ID_DESC,
        "Port mac",
        CTC_CLI_ENABLE,
        CTC_CLI_DISABLE,
        "Bitmap",
        "Bitmap value")
{
    int32 ret = 0;
    uint32 gport;
    uint8 bmp = 0;
    uint8 index = 0;
    bool enable;

    CTC_CLI_GET_UINT32_RANGE("gport", gport, argv[0], 0, CTC_MAX_UINT32_VALUE);
    index = CTC_CLI_GET_ARGC_INDEX("bmp");
    if (index != 0xFF)
    {
        CTC_CLI_GET_UINT8("bmp", bmp, argv[index + 1]);
    }
    if (CLI_CLI_STR_EQUAL("enable", 1))
    {
        enable = TRUE;
    }
    else
    {
        enable = FALSE;
    }

    extern int32
	sys_usw_mac_set_mac_en_emu(uint8 lchip, uint32 mac_id, uint8 mac_enable);
    if (bmp & 0x40)
    {
        ret = sys_usw_mac_set_mac_en_emu(0, gport, enable);
        if (ret < 0)
        {
            ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
            return CLI_ERROR;
        }
    }
    if (bmp & 0x80)
    {
        ret = sys_usw_mac_set_mac_en_emu(4, gport, enable);
        if (ret < 0)
        {
            ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
            return CLI_ERROR;
        }
    }

    return ret;
}
*/
extern int32
drv_usw_emul_load_config(uint8 lchip, char* p_file_name, uint8 check_en);
CTC_CLI(ctc_cli_usw_load_config,
        ctc_cli_usw_load_config_cmd,
        "emulation load cfg CONFIG_FILE_NAME (check-en|)",
        "Emulation",
        "Load",
        "Config",
        "Asic master config file name",
        "Address check")
{
    char cfg_file_ptr[256] = {0};
    uint8 check_en = 0;
    uint8 index = 0;
    index = CTC_CLI_GET_ARGC_INDEX("check-en");
    if (index != 0xFF)
    {
        check_en = 1;
    }

    sal_strcpy(cfg_file_ptr, argv[0]);
    ctc_cli_out("load file: %s \n", argv[0]);
    drv_usw_emul_load_config(0, cfg_file_ptr, check_en);
    return CLI_SUCCESS;
}
#endif

extern int write_entry(uint8 lchip, tbls_id_t id, uint32 index, uint32 offset, uint32 value, uint32 bmp);
extern int32 write_tbl_reg(uint8 lchip, tbls_id_t id, uint64 index, fld_id_t field_id, uint32* value);


extern int32 drv_usw_chip_write(uint8 lchip, uint64 offset, uint32 value);


extern int32 drv_usw_get_field_id_by_string(uint8 lchip, tbls_id_t tbl_id, fld_id_t* field_id, char* name);
extern  int32 drv_usw_get_tbl_id_by_string(uint8 lchip, tbls_id_t* tbl_id, char* name);

CTC_CLI(cli_dbg_tool_write_tbl_fld_reg,
    cli_dbg_tool_write_tbl_reg_fld_cmd,
    "write chip CHIP_ID tbl-reg TBL_REG_ID INDEX (field FIELD_NAME| offset OFFSET) VAL (bmp BMP|)",
    "write chip table or register info",
    "Chip information",
    "Chipid value",
    "Write table or register",
    "Table or register ID name",
    "Table or register entry index <0>",
    "Table/register fileld id name",
    "Table/register field name(string)",
    "Table offset",
    "Table offset value",
    "Set value",
    "Bitmap",
    "Btmap Value")
{
#define TIPS_NONE           0
#define TIPS_TBL_REG        1
#define TIPS_TBL_REG_FIELD  2
    uint32 chip_id = 0;
    uint8 tips_type = TIPS_NONE;
    char* id_name = NULL, *ins_info = NULL;
    char* field_name = NULL;

    uint32 id = 0, ins = 0;
    fld_id_t field_id = 0;
    uint32 index = 0;
    uint32 idx = 0;
    uint32 value[256] = {0};
    uint32 offset = 0xFFFFFFFF;
    int32 ret = 0;
    uint32 bmp = 0;

    CTC_CLI_GET_INTEGER("chipid", chip_id, argv[0]);
    chip_id = chip_id;

    id_name = argv[1];
    ins_info = sal_strstr(id_name, ".");
    if (NULL != ins_info)
    {
        sal_sscanf(ins_info+1, "%u", &ins);
        *ins_info = '\0';
    }

    if(0 != drv_usw_get_tbl_id_by_string(0, &id, id_name))
    {
        ctc_cli_out("can't find tbl %s \n", id_name);
        return CLI_ERROR;
    }
    CTC_CLI_GET_INTEGER("tbl/reg index", index, argv[2]);
    if (NULL != ins_info)
    {
        index += ins<<24;
    }

    idx = CTC_CLI_GET_ARGC_INDEX("bmp");
    if (0xFF != idx)
    {
        CTC_CLI_GET_UINT32("bmp", bmp, argv[idx + 1]);
    }

    if(3 == argc)
    {
        tips_type = TIPS_TBL_REG_FIELD;
    }
    else
    {
        idx = ctc_cli_get_prefix_item(&argv[0], argc, "field", sal_strlen("field"));
        if (0xFF != idx)
        {
            field_name = argv[idx + 1];
            if (0 != drv_usw_get_field_id_by_string(0, id, &field_id, field_name))
            {
                ctc_cli_out("can't find table %s field %s \n", id_name, field_name);
                return CLI_ERROR;
            }

            CTC_CLI_GET_INTEGER_N("field-value", (uint32 *)value, argv[idx + 2]);
        }

        idx = ctc_cli_get_prefix_item(&argv[0], argc, "offset", sal_strlen("offset"));
        if (0xFF != idx)
        {
            CTC_CLI_GET_INTEGER("offset", offset, argv[idx + 1]);
            CTC_CLI_GET_INTEGER_N("field-value", (uint32 *)value, argv[idx + 2]);
        }

    }
    if(TIPS_NONE != tips_type)
    {
        //show_tips_info(tips_type, tip_str, id);
    }
    else
    {
        if(0xFFFFFFFF != offset)
        {
            ret = write_entry(chip_id, id, index, offset, value[0], bmp);
        }
        else
        {
            ret = write_tbl_reg(chip_id, id, (uint64)index | ((uint64)bmp << 32), field_id, value);

            if (ret < 0)
            {
                ctc_cli_out("%s\n", argv[0]);
                return ret;
            }
        }
    }

    return CLI_SUCCESS;
}

/* Cmd format: write address <addr_offset> <value> */
CTC_CLI(cli_dbg_tool_write_addr,
    cli_dbg_tool_write_addr_cmd,
    "write chip CHIP_ID address ADDR_OFFSET WRITE_VALUE  (bmp BMP|)",
    "Write value to address cmd",
    "Chip information",
    "Chip id value",
    "Write address 0xXXXXXXXX <value>",
    "Address value",
    "Value to write",
    "Bitmap",
    "Btmap Value")
{
    uint32 address_offset = 0, chip_id = 0, value = 0;
    int32 ret = 0;
    uint8 arg_index = 0;
    uint32 bmp = 0;

    CTC_CLI_GET_INTEGER("chip_id", chip_id, argv[0]);
    CTC_CLI_GET_INTEGER("address", address_offset, argv[1]);
    CTC_CLI_GET_INTEGER("value", value, argv[2]);

    arg_index = CTC_CLI_GET_ARGC_INDEX("bmp");
    if (0xFF != arg_index)
    {
        CTC_CLI_GET_UINT32("bmp", bmp, argv[arg_index + 1]);
    }

    ret = drv_usw_chip_write(0, (uint64)address_offset | ((uint64)bmp << 32), value);

    if (ret < 0)
    {
        ctc_cli_out("0x%08x address write ERROR! Value = 0x%08x\n", address_offset, value);
    }

    return CLI_SUCCESS;
}
#if defined(TSINGMA) || defined(TSINGMA_MX) || defined(TSINGMA_GX) || defined(ARCTIC)

CTC_CLI(ctc_cli_chip_show_lb_hash_status,
        ctc_cli_chip_show_lb_hash_status_cmd,
        "show lb-hash select-id SELECT_ID (hash-select|hash-control) status",
        CTC_CLI_SHOW_STR,
        "Load banlance hash ",
        "Selector",
        "Value of selector",
        "Hash select",
        "Hash control",
        "Status")
        {

            int32 ret = 0;
            uint8 index = 0;
            ctc_lb_hash_config_t hash_cfg;
            sal_memset(&hash_cfg,0,sizeof(ctc_lb_hash_config_t));
            CTC_CLI_GET_INTEGER("select-id", hash_cfg.sel_id, argv[0]);
            index = CTC_CLI_GET_ARGC_INDEX("hash-select");
            if (0xFF != index)
            {
                hash_cfg.cfg_type = CTC_LB_HASH_CFG_HASH_SELECT;

            }
            index = CTC_CLI_GET_ARGC_INDEX("hash-control");
            if (0xFF != index)
            {
                hash_cfg.cfg_type = CTC_LB_HASH_CFG_HASH_CONTROL;

            }
            
            ret = sys_tsingma_lb_hash_show_hash_cfg(g_api_lchip, hash_cfg);

            if (ret < 0)
            {
                ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
                return CLI_ERROR;
            }
            return ret;

        }
CTC_CLI(ctc_cli_chip_show_lb_hash_template,
        ctc_cli_chip_show_lb_hash_template_cmd,
        "show lb-hash template VALUE",
        CTC_CLI_SHOW_STR,
        "Load banlance hash ",
        "Hash-key template",
        "Value of template")
        {
            int32 ret = 0;
            uint8 temp1 = 0;

            CTC_CLI_GET_INTEGER("value", temp1, argv[0]);
            
            ret = sys_tsingma_lb_hash_show_template(g_api_lchip, temp1);
            if (ret < 0)
            {
                ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
                return CLI_ERROR;
            }
            return ret;
        }
#endif


#endif

extern int32
sys_usw_packet_tx_en(uint8 enable, uint16 pkt_num, uint32 gport_id, uint16 pkt_size);
extern int32
sys_usw_diag_io_test(uint8 lchip, uint8 op_type, char* tbl_name, uint32 entry_num, uint8 direct_io);
CTC_CLI(ctc_cli_chip_pkt_trans,
        ctc_cli_chip_pkt_trans_cmd,
        "chip pkt-trans (enable pkt-num PKT_NUM port GPORT_ID pkt-size PKT_SIZE|disable)",
        "Chip module",
        "Packet trans",
        "Enable",
        "Packet number",
        "VALUE",
        "Port",
        "Gport id",
        "Packet size",
        "Packet size value",
        "Disable")
{
    uint8 index = 0xFF;
    uint8 enable_op = 0;
    uint16 pkt_size = 0;
    uint32 pkt_num = 0;
    uint32 gport_id = 0xFFFF;
    index = CTC_CLI_GET_ARGC_INDEX("enable");
    if (index != 0xFF)
    {
        enable_op = 1;
    }else
    {
        enable_op = 0;
    }
    index = CTC_CLI_GET_ARGC_INDEX("pkt-num");
    if (0xFF != index)
    {
        CTC_CLI_GET_UINT32("pkt-num",pkt_num, argv[index + 1]);
        if(pkt_num<10){
            ctc_cli_out("%% %s, packt num at least 10\n", ctc_get_error_desc(CTC_E_INVALID_PARAM));
            return CLI_ERROR;
        }
    }
    index = CTC_CLI_GET_ARGC_INDEX("port");
    if (0xFF != index)
    {
        CTC_CLI_GET_UINT32("port",gport_id, argv[index + 1]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("pkt-size");
    if (0xFF != index)
    {
        CTC_CLI_GET_UINT16("pkt-size",pkt_size, argv[index + 1]);
    }
    ctc_cli_out("status %s\n",enable_op==1?"enable":"disable");
    ctc_cli_out("Pkt num %u\n",pkt_num);
    ctc_cli_out("Dest-Port 0x%04X\n",gport_id);
    ctc_cli_out("Packt size: %u\n",pkt_size);
    sys_usw_packet_tx_en(enable_op,pkt_num,gport_id,pkt_size);
    return CLI_SUCCESS;
}

#if (FEATURE_MODE == 0) && defined E_UNIT
extern int32
sys_usw_eunit_show_dbg_info(uint8 lchip, uint8 eunit_id);
CTC_CLI(ctc_cli_eunit_show_dbg_info,
        ctc_cli_eunit_show_dbg_info_cmd,
        "show eunit ID debug-info ",
        "Show",
        "Eunit",
        "Eunit ID",
        "Debug Info")
{
    int32 ret = 0;
    uint8 eunit_id = 0;

    CTC_CLI_GET_UINT8("eunit-id", eunit_id, argv[0]);
    ret = sys_usw_eunit_show_dbg_info(g_api_lchip, eunit_id);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

extern int32
sys_usw_eunit_clear_dma_stats(uint8 lchip, uint8 eunit_id);
CTC_CLI(ctc_cli_eunit_clear_dma_stats,
        ctc_cli_eunit_clear_dma_stats_cmd,
        "clear eunit ID dma stats ",
        "Clear",
        "Eunit",
        "Eunit ID",
        "DMA",
        "Stats")
{
    int32 ret = 0;
    uint8 eunit_id = 0;

    CTC_CLI_GET_UINT8("eunit-id", eunit_id, argv[0]);
    ret = sys_usw_eunit_clear_dma_stats(g_api_lchip, eunit_id);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

extern int32
sys_usw_eunit_show_dma_stats(uint8 lchip, uint8 eunit_id);
extern int32
sys_usw_eunit_show_dma_status(uint8 lchip, uint8 eunit_id);
CTC_CLI(ctc_cli_eunit_show_dma_stats_status,
        ctc_cli_eunit_show_dma_stats_status_cmd,
        "show eunit ID dma (stats|status)",
        "Show",
        "Eunit",
        "Eunit ID",
        "DMA",
        "Statistic",
        "Status")
{
    int32 ret = 0;
    uint8 eunit_id = 0;
    uint8 index = 0;
    uint8 lchip = 0;

    CTC_CLI_GET_UINT8("eunit-id", eunit_id, argv[0]);

    lchip = g_api_lchip;

    index = CTC_CLI_GET_ARGC_INDEX("stats");
    if (index != 0xFF)
    {
        ret = sys_usw_eunit_show_dma_stats(lchip, eunit_id);
    }
    else
    {
        ret = sys_usw_eunit_show_dma_status(lchip, eunit_id);
    }

    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}
extern int32
sys_usw_eunit_show_cpu_reason_info(uint8 lchip, uint8 eunit_id);
CTC_CLI(ctc_cli_eunit_show_cpu_reason_info,
        ctc_cli_eunit_show_cpu_reason_info_cmd,
        "show eunit ID cpu-reason ",
        "Show",
        "Eunit",
        "Eunit ID",
        "CPU Reason Info")
{
    int32 ret = 0;
    uint8 eunit_id = 0;
 
    CTC_CLI_GET_UINT8("eunit-id", eunit_id, argv[0]);
    ret = sys_usw_eunit_show_cpu_reason_info(g_api_lchip, eunit_id);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

extern int32
sys_usw_eunit_show_pclog(uint8 lchip, uint8 eunit_id);
CTC_CLI(ctc_cli_eunit_show_pclog,
        ctc_cli_eunit_show_pclog_cmd,
        "show eunit ID pc-log ",
        "Show",
        "Eunit",
        "Eunit ID",
        "Pc log")
{
    int32 ret = 0;
    uint8 eunit_id = 0;

    CTC_CLI_GET_UINT8("eunit-id", eunit_id, argv[0]);

    ret = sys_usw_eunit_show_pclog(g_api_lchip, eunit_id);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

extern int32
sys_usw_euint_tbl_rw(uint8 lchip, uint8 eunit_id, uint32 tbl_id, uint32 tbl_idx, uint32 opbmp, uint8 data, uint8 data_mask, uint8 op_type);


CTC_CLI(ctc_cli_eunit_tbl_rw,
        ctc_cli_eunit_tbl_rw_cmd,
        "eunit ID (read | write ) TABLEID index INDEX (data DATA |) (mask MASK|) (op-bmp OPBMP|)",
        "Eunit",
        "Eunit ID",
        "Read operation",
        "Write operation",
        "Table id",
        "Index",
        "Index value",
        "Data to write",
        "Data, a byte",
        "Data mask",
        "MASK",
        "Operation bitmap",
        "Operation bitmap value")
{
    int32 ret = 0;
    uint8 eunit_id = 0;
    uint8 index = 0;
    uint8 op_type = 0;/* 0 read, 1 write , 2 mask write */
    uint32 tbl_id = 0;
    uint32 tbl_idx = 0;
    uint32 opbmp = 0;
    uint8 data = 0;
	uint8 mask = 0xff;


    CTC_CLI_GET_UINT8("eunit-id", eunit_id, argv[0]);
    if (CLI_CLI_STR_EQUAL("read", 1))
    {
        op_type = 0;
    }
    else if (CLI_CLI_STR_EQUAL("write", 1))
    {
        op_type = 1;
    } 
    CTC_CLI_GET_UINT32("tbl-id", tbl_id, argv[2]);
    CTC_CLI_GET_UINT32("start_idx", tbl_idx, argv[3]);


    index = CTC_CLI_GET_ARGC_INDEX("op-bmp");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_UINT32("op-bmp", opbmp, argv[index + 1]);
    }

    index = CTC_CLI_GET_ARGC_INDEX("data");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_UINT8("data", data, argv[index + 1]);
    }

    index = CTC_CLI_GET_ARGC_INDEX("mask");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_UINT8("mask", mask, argv[index + 1]);
		op_type = 2;
    }

    ret = sys_usw_euint_tbl_rw(g_api_lchip, eunit_id, tbl_id, tbl_idx, opbmp, data, mask, op_type);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

extern int32
sys_usw_eunit_show_dma_desc(uint8 lchip, uint8 eunit_id, uint8 chan_id, uint32 start_idx, uint32 end_idx);
CTC_CLI(ctc_cli_eunit_show_dma_desc,
        ctc_cli_eunit_show_dma_desc_cmd,
        "show eunit ID dma desc chan CHANID start-idx STARTIDX end-idx ENDIDX",
        "Show",
        "Eunit",
        "Eunit ID",
        "Dma",
        "Descriptor",
        "Dma channel id",
        "Dma channel id value",
        "Descriptor start index",
        "Index value",
        "Descriptor end index",
        "Index value")
{
    int32 ret = 0;
    uint8 eunit_id = 0;
    uint8 chan_id = 0;
    uint32 start_idx = 0;
    uint32 end_idx = 0;

    CTC_CLI_GET_UINT8("eunit-id", eunit_id, argv[0]);
    CTC_CLI_GET_UINT8("chan-id", chan_id, argv[1]);
    CTC_CLI_GET_UINT32("start-idx", start_idx, argv[2]);
    CTC_CLI_GET_UINT32("end-idx", end_idx, argv[3]);

    ret = sys_usw_eunit_show_dma_desc(g_api_lchip, eunit_id, chan_id, start_idx, end_idx);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

extern int32
sys_usw_eunit_show_mem(uint8 lchip,       uint32 addr, uint32 len);
CTC_CLI(ctc_cli_eunit_show_mem,
        ctc_cli_eunit_show_mem_cmd,
        "eunit dump address ADDR len LEN ",
        "Eunit",
        "Dump",
        "Eunit memory address",
        "Address value",
        "Length of memory to show",
        "Length in words")
{
    int32 ret = 0;
    uint32 addr = 0;
    uint32 len = 0;

    CTC_CLI_GET_UINT32("address", addr, argv[0]);
    CTC_CLI_GET_UINT32("length", len, argv[1]);

    ret = sys_usw_eunit_show_mem(g_api_lchip, addr, len);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

extern int32
sys_usw_eunit_show_io_log(uint8 lchip, uint8 eunit_id, uint8 clear_en);
CTC_CLI(ctc_cli_eunit_show_io_log,
        ctc_cli_eunit_show_io_log_cmd,
        "show eunit ID io-log (clear|) ",
        "Show",
        "Eunit",
        "Eunit ID",
        "I/O log",
        "Clear Log")
{
    int32 ret = 0;
 
    uint8 index = 0;
    uint8 eunit_id = 0;
    uint8 clear_en = 0;

    CTC_CLI_GET_UINT8("eunit-id", eunit_id, argv[0]);
    index = CTC_CLI_GET_ARGC_INDEX("clear");
    if (index != 0xFF)
    {
        clear_en = 1;
    }

    ret = sys_usw_eunit_show_io_log(g_api_lchip, eunit_id, clear_en);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

extern int32
sys_usw_eunit_set_run_status(uint8 lchip, uint8 eunit_id, uint32 run_status);
CTC_CLI(ctc_cli_eunit_set_status,
        ctc_cli_eunit_set_status_cmd,
        "eunit ID (running | suspend)",
        "Eunit",
        "Eunit ID",
        "Running",
        "Suspend")
{
    int32 ret = 0;

    uint8 index = 0;
    uint8 eunit_id = 0;
    uint32 status = 0;

    CTC_CLI_GET_UINT8("eunit-id", eunit_id, argv[0]);
    index = CTC_CLI_GET_ARGC_INDEX("running");
    if (index != 0xFF)
    {
        status = 1;
    }
    index = CTC_CLI_GET_ARGC_INDEX("suspend");
    if (index != 0xFF)
    {
        status = 2;
    }
 
    ret = sys_usw_eunit_set_run_status(g_api_lchip, eunit_id, status);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}
extern int32
sys_usw_eunit_get_cfg(uint8 lchip, uint8 type, void* p_cfg);
CTC_CLI(ctc_cli_eunit_show_app_alive_cnt,
        ctc_cli_eunit_show_app_alive_cnt_cmd,
        "show eunit ID app-id ID alive-cnt",
        "Show",
        "Eunit",
        "Eunit ID",
        "app id",
        "APP ID",
        "alive cnt")
{
    int32 ret = 0;
    ctc_eunit_status_t app_alive={0};

    CTC_CLI_GET_UINT8("eunit-id", app_alive.eunit_id, argv[0]);
    CTC_CLI_GET_UINT32("app-id", app_alive.app_id, argv[1]);

    ret = ctcs_chip_get_property(g_api_ldev, CTC_CHIP_PROP_EUNIT_APP_STATUS, &app_alive);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    ctc_cli_out("app:%d, cnt:%d\n", app_alive.app_id, app_alive.alive_cnt);
    return CLI_SUCCESS;
}

extern int32
sys_usw_eunit_show_version(uint8 lchip, uint8 eunit_id);

CTC_CLI(ctc_cli_usw_chip_show_eunit_version,
        ctc_cli_usw_chip_show_eunit_version_cmd,
        "show eunit ID version",
        "Show",
        "Eunit",
        "Eunit ID",
        "Version")
{
    uint8 eunit_id = 0;
    int32 ret = 0;
    CTC_CLI_GET_UINT8("eunit-id", eunit_id, argv[0]);
    ret = sys_usw_eunit_show_version(g_api_lchip, eunit_id);
        if (ret < 0)
        {
            ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
            return CLI_ERROR;
        }
    return CLI_SUCCESS;
}

extern int32
sys_usw_eunit_show_status(uint8 lchip, uint8 level, void* p_params);

CTC_CLI(ctc_cli_usw_chip_show_eunit_status,
        ctc_cli_usw_chip_show_eunit_status_cmd,
        "show eunit ID status {(all | app-id APP_ID)|}",
        "Show",
        "Eunit",
        "Eunit ID",
        "show eunit info",
        "by levels",
        "all app info",
        "app id",
        "APP ID")
{
    uint8 index = 0xFF;
    uint8 level = 1;
    int32 ret = 0;

    sys_usw_eunit_status_params_t params;

    memset(&params, 0, sizeof(params));
    
    CTC_CLI_GET_UINT8("eunit-id", params.eunit_id, argv[0]);

    index = CTC_CLI_GET_ARGC_INDEX("all");
    if (INDEX_VALID(index))
    {
        level = 0;
    }

    index = CTC_CLI_GET_ARGC_INDEX("app-id");
    if (INDEX_VALID(index))
    {
        level = 2;
        CTC_CLI_GET_UINT32("group id", params.app_id, argv[index + 1]);
        
    }    
    ret = sys_usw_eunit_show_status(g_api_lchip, level, &params);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}

#endif

CTC_CLI(ctc_cli_usw_chip_free_rsv_resource,
        ctc_cli_usw_chip_free_rsv_resource_cmd,
        "chip free reserved resource",
        "Chip",
        "Free",
        "Reserved",
        "Resource")
{
    int32 ret = 0;
 
    ret = sys_usw_chip_free_rsv_resource(g_api_lchip);
    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

extern int32 drv_show_status(uint8 lchip);
CTC_CLI(ctc_cli_usw_chip_show_drv_status,
        ctc_cli_usw_chip_show_drv_status_cmd,
        "show drv status",
        "Show",
        "Drv module",
        "Status")
{
    int32 ret = CLI_SUCCESS;

    ret = drv_show_status(g_api_lchip);
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return ret;
}

CTC_CLI(ctc_cli_usw_chip_set_serdes_download_fw,
        ctc_cli_usw_chip_set_serdes_download_fw_cmd,
        "chip serdes SERDES_ID download-firmware (default | debug)",
        "Chip module",
        "Serdes",
        "Physical serdes id",
        "Download firmware",
        "Use default firmware",
        "Use debug firmware")
{
    int32  ret   = CLI_SUCCESS;
    uint8  index = 0;
    uint8  flag  = 0;
    uint16 serdes_id = 0;

    CTC_CLI_GET_UINT16("serdes", serdes_id, argv[0]);

    index = CTC_CLI_GET_ARGC_INDEX("default");
    if (0xFF != index)
    {
        flag = 0;
    }

    index = CTC_CLI_GET_ARGC_INDEX("debug");
    if (0xFF != index)
    {
        flag = 1;
    }

    ret = sys_usw_dmps_serdes_download_firmware(g_api_lchip, serdes_id, flag);
    return ret;
}


int32
ctc_usw_chip_cli_init(void)
{
    install_element(CTC_SDK_MODE, &ctc_cli_usw_datapath_show_status_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_datapath_show_xpipe_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_datapath_show_info_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_set_ecc_simulation_store_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_chip_sdb_global_config_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_chip_show_sdb_status_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_sdb_set_marker_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_sdb_show_changed_table_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_chip_check_table_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_chip_dump_table_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_chip_show_ecc_status_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_set_ecc_simulation_idx_cmd);

    install_element(CTC_CMODEL_MODE, &ctc_cli_usw_master_queue_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_debug_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_chip_set_glb_acl_lkup_en_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_chip_get_glb_acl_lkup_en_cmd);

    install_element(CTC_SDK_MODE, &ctc_cli_chip_set_ipmc_config_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_chip_show_ipmc_config_cmd);

#if defined(TSINGMA) || defined(TSINGMA_MX) || defined(TSINGMA_GX) || defined(ARCTIC)
    install_element(CTC_SDK_MODE, &ctc_cli_chip_show_lb_hash_status_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_chip_show_lb_hash_template_cmd);
#endif


    install_element(CTC_SDK_MODE, &cli_dbg_tool_write_tbl_reg_fld_cmd);
    install_element(CTC_SDK_MODE, &cli_dbg_tool_write_addr_cmd);

    install_element(CTC_SDK_MODE, &ctc_cli_chip_show_status_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_chip_show_wb_version_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_show_mcu_version_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_show_mcu_info_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_set_mcu_on_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_show_mcu_status_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_parser_set_hash_mask_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_chip_dump_db_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_chip_set_search_depth_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_chip_get_search_depth_cmd);

    install_element(CTC_SDK_MODE, &ctc_cli_chip_pkt_trans_cmd);
#if (FEATURE_MODE == 0) && defined E_UNIT
    install_element(CTC_SDK_MODE, &ctc_cli_eunit_show_dbg_info_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_eunit_show_dma_stats_status_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_eunit_clear_dma_stats_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_eunit_show_cpu_reason_info_cmd);
	install_element(CTC_SDK_MODE, &ctc_cli_eunit_show_pclog_cmd);
   	install_element(CTC_INTERNAL_MODE, &ctc_cli_eunit_tbl_rw_cmd);
   	install_element(CTC_SDK_MODE, &ctc_cli_eunit_show_dma_desc_cmd);
   	install_element(CTC_SDK_MODE, &ctc_cli_eunit_show_mem_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_eunit_show_io_log_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_eunit_set_status_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_eunit_show_app_alive_cnt_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_chip_show_eunit_version_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_chip_show_eunit_status_cmd);
#endif
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_free_rsv_resource_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_show_drv_status_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_set_serdes_download_fw_cmd);


    return 0;
}

int32
ctc_usw_chip_cli_deinit(void)
{
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_datapath_show_status_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_datapath_show_xpipe_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_datapath_show_info_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_set_ecc_simulation_store_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_chip_sdb_global_config_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_chip_show_ecc_status_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_set_ecc_simulation_idx_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_chip_show_sdb_status_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_sdb_set_marker_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_sdb_show_changed_table_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_chip_check_table_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_chip_dump_table_cmd);

    uninstall_element(CTC_CMODEL_MODE, &ctc_cli_usw_master_queue_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_debug_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_chip_set_glb_acl_lkup_en_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_chip_get_glb_acl_lkup_en_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_chip_show_wb_version_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_chip_set_ipmc_config_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_chip_show_ipmc_config_cmd);

#if defined(TSINGMA) || defined(TSINGMA_MX) || defined(TSINGMA_GX) || defined(ARCTIC)
    uninstall_element(CTC_SDK_MODE, &ctc_cli_chip_show_lb_hash_status_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_chip_show_lb_hash_template_cmd);
#endif
    uninstall_element(CTC_SDK_MODE, &ctc_cli_chip_show_status_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_show_mcu_version_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_show_mcu_info_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_set_mcu_on_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_show_mcu_status_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_parser_set_hash_mask_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_chip_dump_db_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_chip_set_search_depth_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_chip_get_search_depth_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_chip_pkt_trans_cmd);
	uninstall_element(CTC_SDK_MODE, &cli_dbg_tool_write_tbl_reg_fld_cmd);
    uninstall_element(CTC_SDK_MODE, &cli_dbg_tool_write_addr_cmd);
#if (FEATURE_MODE == 0) && defined E_UNIT
    uninstall_element(CTC_SDK_MODE, &ctc_cli_eunit_show_dbg_info_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_eunit_show_dma_stats_status_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_eunit_clear_dma_stats_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_eunit_show_cpu_reason_info_cmd);
	uninstall_element(CTC_SDK_MODE, &ctc_cli_eunit_show_pclog_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_eunit_tbl_rw_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_eunit_show_dma_desc_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_eunit_show_mem_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_eunit_show_io_log_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_eunit_set_status_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_eunit_show_app_alive_cnt_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_chip_show_eunit_version_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_chip_show_eunit_status_cmd);
#endif
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_free_rsv_resource_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_show_drv_status_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_usw_chip_set_serdes_download_fw_cmd);

#ifdef EMULATION_ENV
    //uninstall_element(CTC_SDK_MODE, &ctc_usw_chip_cli_port_set_mac_en_emu_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_load_config_cmd);
#endif
    return 0;
}

